﻿namespace Server.Proto
{
    /// <summary>
    /// 协议错误码
    /// </summary>
    public enum MessageErrorCode
    {
        Success = 0,
        
        /// <summary>
        /// 参数无效
        /// </summary>
        ParamInvalid = 1,
        
        /// <summary>
        /// 配置未找到
        /// </summary>
        ConfigNotFound = 2,

        #region [客户端框架使用 1-1000000]

        /// <summary>
        /// 应答包类型不匹配
        /// </summary>
        ResponseTypeNotMatch = 1001,

        /// <summary>
        /// 应答包为空
        /// </summary>
        ResponseIsNull,

        /// <summary>
        /// 请求捕获到异常
        /// </summary>
        RequestCatchException,
        
        /// <summary>
        /// 请求已被取消
        /// </summary>
        RequestHasBeenCanceled,

        /// <summary>
        /// 小于该值的用于客户端框架使用
        /// </summary>
        ClientErrorCodeEnd = 1000000,

        #endregion

        #region [协议交互使用 1000001-2000000]

        /// <summary>
        /// 无效的路由
        /// </summary>
        InvalidRoute = 1000001,
        
        /// <summary>
        /// 服务器内部错误
        /// </summary>
        ServerInternalError = 1000002,
        
        /// <summary>
        /// 参数错误
        /// </summary>
        ParametersError = 1000003,
        
        /// <summary>
        /// 请求超时
        /// </summary>
        RequestTimeOut = 1000004,
        
        /// <summary>
        /// 网络已关闭
        /// </summary>
        NetworkClosed = 1000005,
        
        /// <summary>
        /// 服务器已关闭
        /// </summary>
        ServerClosed = 1000006,

        #region [登录 1000100 - 1000199]
        
        /// <summary>
        /// 登录票据无效
        /// </summary>
        LoginTokenIsInvalid = 1000100,
        
        /// <summary>
        /// 登录账号已被删除
        /// </summary>
        LoginAccountHasBeenDeleted,
        
        /// <summary>
        /// 重连票据无效
        /// </summary>
        ReconnectTokenIsInvalid,
        
        /// <summary>
        /// 角色不存在
        /// </summary>
        RoleNotExists,
        
        /// <summary>
        /// 账号不存在
        /// </summary>
        AccountNotExists,
        
        /// <summary>
        /// 服务器信息已存在
        /// </summary>
        ServerInfoExists,
        
        /// <summary>
        /// 服务器信息不存在
        /// </summary>
        ServerInfoNotExists,

        #endregion

        #endregion

        #region [客户端业务使用 2000000-*]

        /// <summary>
        /// 大于该值的用户客户端业务使用
        /// </summary>
        Max = 2000000,

        #endregion
    }

    public static class MessageErrorCodeExtensions
    {
        public static int AsInt(this MessageErrorCode errorCode)
        {
            return (int)errorCode;
        }
    }
}